<template lang="pug">
  .vue__component__root(:id='_uid')
    v-container(grid-list-xl)
      v-layout(wrap row)
        v-flex(lg3)
          v-card(color="cyan" @click="resetDB" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 重置数据库
        v-flex(lg3)
          v-card(color="cyan" @click="mock20Assets" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 创建20条普通资产
        v-flex(lg3)
          v-card(color="cyan" @click="mock20AssetStocks" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 创建20条批量资产
        v-flex(lg3)
          v-card(color="cyan" @click="mock20FilterableBundles" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 创建20条资产组合
        v-flex(lg3)
          v-card(color="cyan" @click="mock10Orders" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 创建10条订单
        v-flex(lg3)
          v-card(color="cyan" @click="mock10FeeRules" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 创建10计费规则
        v-flex(lg3)
          v-card(color="cyan" @click="testConfirmPlugin" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 testConfirmPlugin
        v-flex(lg3)
          v-card(color="cyan" @click="clearCache" hover)
            v-card-text
              div.text-sm-center.py-3.display-1 清除缓存
</template>
<script>
export default {
  props: [],
  methods: {
    resetDB() {
      if (confirm('重置当前数据库，你确定吗？')) {
        this.$loading('数据库重置中...')
        this.$store.dispatch('developerConsole/resetDB').then(()=>{
          this.$loading.close()
          this.$toast.center('重置成功')
        }).catch(()=>{
          this.$loading.close()
          this.$toast.center('重置失败')
        })
      }
    },
    mock20Assets() {
      this._exec('developerConsole/mock20Assets')
    },
    mock20AssetStocks() {
      this._exec('developerConsole/mock20AssetStocks')
    },
    mock20AssetBundles(){
      this._exec('developerConsole/mock20AssetBundles')
    },
    mock20FilterableBundles(){
      this._exec('developerConsole/mock20FilterableBundles')
    },
    mock10Orders() {
      this._exec('developerConsole/mock10Orders')
    },
    mock10FeeRules(){
      this._exec('developerConsole/mock10FeeRules')
    },
    _exec(url){
      this.$loading("资产创建中...")
      this.$store.dispatch(url).then(()=>{
        this.$loading.close()
        this.$toast.center('创建成功')
      }).catch(()=>{
        this.$loading.close()
        this.$toast.center('创建失败')
      })
    },
    clearCache(){
      this.$loading("清理中...")
      this.$store.dispatch('developerConsole/clearCache').then(()=>{
          this.$loading.close()
          this.$toast.center('清理成功')
        }).catch(()=>{
          this.$loading.close()
          this.$toast.center('清理失败')
        })
    },
    testConfirmPlugin() {
      this.$confirm({
        body: "it's me"
      }).then(()=> {
        alert('resolved')
      }).catch(()=>{
        alert('rejected')
      })
    }
  },
  computed: {},
  data() {
    return {}
  }
}
</script>